<template>
  <div class="films">
    <div class="film_Line">
      <div class="firstLine">
        <div class="ff1">类型:</div>
        <ul class="firstList">
          <li
            v-for="(item, index) in typeList"
            :key="index"
            :class="selectType === item ? 'active' : ''"
            @click="handleTypeSelect(item)"
          >
            <router-link :to="'/films?region=' + selectRegion + '&type=' + item"
              ><a>{{ item }}</a></router-link
            >
          </li>
        </ul>
      </div>
      <div class="secondLine">
        <div class="ff2">地区:</div>
        <ul class="secondList">
          <li
            v-for="(item, index) in regionList"
            :key="index"
            :class="selectRegion === item ? 'active' : ''"
            @click="handleRegionSelect(item)"
          >
            <router-link :to="'/films?region=' + item + '&type=' + selectRegion"
              ><a>{{ item }}</a></router-link
            >
          </li>
        </ul>
      </div>
    </div>
    <el-row
      :gutter="20"
      style="padding-top: 60px; width: 1200px; margin-left: 40px"
    >
      <el-col
        style="padding-bottom: 50px; text-align: center"
        v-for="(item, index) in filmList"
        :key="index"
        :span="4"
      >
        <router-link to="/film/detail">
          <el-card shadow="hover" :body-style="{ padding: '0px' }">
            <img
              style="width: 100%; height: 220px; padding-bottom: 10px"
              :src="item.cover"
              alt=""
            />
            <span class="s">{{ item.name }}</span>
          </el-card>
        </router-link>
      </el-col>
    </el-row>
  </div>
</template>
<script>
import { ListtotalFilm } from "@/api/film";

export default {
  name: "Films",
  data() {
    return {
      selectType: "全部",
      selectRegion: "全部",
      typeList: [
        "全部",
        "家庭",
        "惊悚",
        "科幻",
        "爱情",
        "动作",
        "喜剧",
        "恐怖",
        "悬疑",
        "犯罪",
        "冒险",
        "战争",
        "历史",
        "武侠",
        "传记",
        "古装",
        "其他",
      ],
      regionList: [
        "全部",
        "内地",
        "香港",
        "台湾",
        "美国",
        "韩国",
        "日本",
        "泰国",
        "印度",
        "法国",
        "英国",
        "德国",
        "其他",
      ],
      filmList: [
        // {
        //   name: "电影1",
        //   cover_show: require("../assets/filmImg/xxyw.jpg"),
        // },
        // {
        //   name: "电影1",
        //   cover_show: require("../assets/filmImg/lihuanying.jpg"),
        // },
      ],
    };
  },
  mounted() {
    ListtotalFilm().then((res) => {
      if (res.code == 200) {
        this.filmList = res.data;
      }
    });
  },
  methods: {
    handleTypeSelect(item) {
      this.selectType = item;
      this.reloadFilmList();
    },
    //点击地区
    handleRegionSelect(item) {
      this.selectRegion = item;
      this.reloadFilmList();
    },
    // reloadFilmList() {
    //   FindFilmByRegionAndType().then((res) => {
    //     this.filmList = res.data;
    //   });
    // },
  },
};
</script>
<style lang="scss">
.films {
  width: 1400px;
  height: 160px;
  // background: pink;
  margin: 10px auto;
  .film_Line {
    width: 1300px;
    height: 150px;
    margin: 0 auto;
    border: 2px solid #eee;
    .firstLine {
      width: 1250px;
      height: 50px;
      margin: 15px auto;
      // background: yellow;
      .ff1 {
        float: left;
        width: 50px;
        height: 50px;
        line-height: 50px;
        // margin-top: 10px;
        // background: blanchedalmond;
      }
      .firstList {
        width: 1200px;
        height: 50px;
        float: left;
        // list-style: none;
        li {
          // border-radius: 14px;
          // border: 1px solid red;
          padding: 3px 9px;
          display: inline-block;
          margin-left: 12px;
          margin-top: 10px;
          // float: left;
        }
        a {
          color: black;
          text-decoration: none;
        }
        li.active a {
          border-radius: 14px;
          padding: 3px 6px;
          color: white;
          background: #f34d41;
        }
      }
      // .firstList li.active {
      //   background: #f34d41;
      //   color: #fff !important;
      // }
    }

    .secondLine {
      width: 1200px;
      height: 50px;
      float: left;
      margin-left: 25px;
      // background: #f34d41;
      // list-style: none;
      .ff2 {
        float: left;
        width: 50px;
        height: 50px;
        line-height: 50px;
        // margin-top: 10px;
        // background: blanchedalmond;
      }
      .secondList {
        width: 1200px;
        height: 50px;
        // float: left;
        // list-style: none;
        li {
          // border-radius: 14px;
          // border: 1px solid red;
          padding: 3px 9px;
          display: inline-block;
          margin-left: 12px;
          margin-top: 10px;
          // float: left;
        }
        a {
          color: black;
          text-decoration: none;
        }
        li.active a {
          border-radius: 14px;
          padding: 3px 6px;
          color: white;
          background: #f34d41;
        }
      }
    }
  }
  .s {
    width: 100px;
    height: 35px;
    // background: yellow;
    display: inline-block;
  }
}
</style>